package com.lg.algorithm.ms;

import java.util.Arrays;

/**
 *  有序数组 删除重复项
 *      返回 删除完的个数
 *
 *  12334
 *
 *  不能新建空间
 *
 */
public class DD {

    public static void main(String[] args) {
        int[] nums = {1,2,3,3,4,5,6,6,7};
        System.out.println(getNumsCount(nums));
        System.out.println(Arrays.toString(nums));
    }

    private static int getNumsCount(int[] nums) {
        int pre = 0;
        int value = nums[0];
        for (int i = 1; i < nums.length; i++) {
            if (value != nums[i]) {
                value = nums[i];
                pre = pre + 1;
                nums[pre] = value;
            }
        }

        return pre + 1;

    }
}
